<?php
//1.开启session机制
session_start();
//2.取session
$user = $_SESSION['user'];

//3.判断用户存不存在
if($user == null){
    header('location: login.php');
}
?>